package com.sc.portal.service.impl;

import com.sc.common.pojo.CommonResult;
import com.sc.common.utils.HttpClientUtil;
import com.sc.common.utils.JsonUtils;
import com.sc.portal.pojo.OrderInfo;
import com.sc.portal.service.OrderService;
import org.apache.http.client.methods.HttpPost;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * @auther sc
 * @Date 2017/11/8
 */
@Service
public class OrderServiceImpl implements OrderService {
    @Value("${ORDER_BASE_URL}")
    private String ORDER_BASE_URL;


    @Override
    public String createOrder(OrderInfo orderInfo) {
        String json = JsonUtils.objectToJson(orderInfo);
        String s = HttpClientUtil.doPostJson(ORDER_BASE_URL + "/create", json);
        CommonResult result = CommonResult.format(s);
        String orderId = result.getData().toString();
        return orderId;
    }
}
